package com.algorithm;

public class UglyNum {
    public static void main(String[] args) {

    }

    public int firstBadVersion(int n,int badVersion) {
        int beg = 1;
        int end = n;
        while(beg<end){
            int mid = beg+(end-beg)/2;
            if(badVersion>=mid){
                end = mid;
            }else{
                beg = mid + 1;
            }
        }
        return beg ;
    }
}
